Skip to content

feat(cli): add init subcommand for project scaffolding#99

Open
izumin5210 wants to merge 3 commits intomainfrom
izumin5210/init
Open

feat(cli): add init subcommand for project scaffolding#99
izumin5210 wants to merge 3 commits intomainfrom
izumin5210/init

Conversation

@izumin5210
Copy link
Owner

Summary

  • Add gqlkit init command to initialize a new gqlkit project
  • Implement directory resolution with upward search for project root
  • Detect existing gqlkit configurations to skip redundant file generation
  • Generate initial files: context.ts, gqlkit.ts, schema.ts, schema/.gitkeep
  • Update package.json with required dependencies (@gqlkit-ts/runtime, @graphql-tools/schema)
  • Auto-detect package manager (npm, yarn, pnpm) and run install command
  • Integrate with gqlkit gen to generate initial schema

Test plan

  • Unit tests for each orchestrator component (59 tests)
  • Integration tests for full initialization flow
  • Tests for existing project detection and file skip logic
  • Tests for package manager detection
  • Full test suite passes (350/350 tests)

🤖 Generated with Claude Code

Add `gqlkit init` command to initialize a new gqlkit project with:

- Directory resolution with upward search for project root
- Existing gqlkit configuration detection to skip redundant files
- Initial file generation (context.ts, gqlkit.ts, schema.ts, .gitkeep)
- Package.json dependency updates (@gqlkit-ts/runtime, @graphql-tools/schema)
- Package manager detection (npm, yarn, pnpm) and auto-install
- Integration with gqlkit gen command

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 18, 2026 11:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a comprehensive gqlkit init command to initialize new gqlkit projects with automatic scaffolding. The implementation includes directory resolution, existing project detection, file generation, dependency management, and automatic package installation.

Changes:

  • Adds init subcommand with orchestrator modules for project initialization
  • Implements smart detection of existing gqlkit setups to avoid redundant file generation
  • Integrates with gqlkit gen command to generate initial schema files

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/cli/src/init-orchestrator/subprocess-runner.ts Utility for executing shell commands with stdio capture
packages/cli/src/init-orchestrator/subprocess-runner.test.ts Test coverage for subprocess execution
packages/cli/src/init-orchestrator/package-manager-detector.ts Auto-detects npm, yarn, or pnpm from package.json field or lockfiles
packages/cli/src/init-orchestrator/package-manager-detector.test.ts Test coverage for package manager detection logic
packages/cli/src/init-orchestrator/package-json-updater.ts Updates package.json with required dependencies
packages/cli/src/init-orchestrator/package-json-updater.test.ts Test coverage for package.json modification
packages/cli/src/init-orchestrator/file-generator.ts Generates initial project files (context.ts, gqlkit.ts, schema.ts)
packages/cli/src/init-orchestrator/file-generator.test.ts Test coverage for file generation and skip logic
packages/cli/src/init-orchestrator/existing-project-detector.ts Scans directories for existing createGqlkitApis usage
packages/cli/src/init-orchestrator/existing-project-detector.test.ts Test coverage for existing project detection
packages/cli/src/init-orchestrator/directory-resolver.ts Resolves project root by searching upward for package.json or config
packages/cli/src/init-orchestrator/directory-resolver.test.ts Test coverage for directory resolution
packages/cli/src/init-orchestrator/index.ts Exports all orchestrator module interfaces and functions
packages/cli/src/commands/init.ts Main init command implementation coordinating all orchestrator modules
packages/cli/src/commands/init.test.ts Integration tests for full init command flow
packages/cli/src/cli.ts Registers init command with CLI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

This comment has been minimized.

izumin5210 and others added 2 commits January 18, 2026 21:14
Replace `pwd` with `node -e "console.log(process.cwd())"` to fix
Windows CI failures. Git Bash's pwd returns Unix-style paths (/tmp/...)
which don't match Node.js tmpdir() Windows paths (C:\Users\...).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Capture error details in subprocess-runner error handler
- Remove redundant conditional for installArgs
- Simplify sourceDir resolution logic in directory-resolver

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Code Metrics Report

main (a493e71) #99 (d5aca1c) +/-
Coverage 85.7% 85.8% +0.0%
Test Execution Time 4m36s 4m40s +4s
Details
  |                     | main (a493e71) | #99 (d5aca1c) |  +/-  |
  |---------------------|----------------|---------------|-------|
+ | Coverage            |          85.7% |         85.8% | +0.0% |
  |   Files             |             55 |            63 |    +8 |
  |   Lines             |           3416 |          3606 |  +190 |
+ |   Covered           |           2930 |          3094 |  +164 |
- | Test Execution Time |          4m36s |         4m40s |   +4s |

Code coverage of files in pull request scope (0.0% → 86.3%)

Files Coverage +/- Status
packages/cli/src/commands/init.ts 66.1% +66.1% added
packages/cli/src/init-orchestrator/directory-resolver.ts 100.0% +100.0% added
packages/cli/src/init-orchestrator/existing-project-detector.ts 100.0% +100.0% added
packages/cli/src/init-orchestrator/file-generator.ts 100.0% +100.0% added
packages/cli/src/init-orchestrator/index.ts 0.0% 0.0% added
packages/cli/src/init-orchestrator/package-json-updater.ts 100.0% +100.0% added
packages/cli/src/init-orchestrator/package-manager-detector.ts 92.0% +92.0% added
packages/cli/src/init-orchestrator/subprocess-runner.ts 80.0% +80.0% added

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant